var itemId="0";
var sessionId="";
var bidMode = "";
var line = "F"; //是否串行
var itermIds = "";
var myLevel = "";//当前登录人针对此标的的行权级别
var decimalCount = "";
var currentBidTimes="-1";
var firstValue = "";
var lastValue = "";
var increment = "0";
var incrementGroup ="";
var incrementValue ="";
var onceValue = "0";
var allowFirstValue = "";
var updateTimes="";
var loginUser = "";//当前登录人
var lastUser = "";//最高报价人
var vFlag = "";
var groupId ="0";
var itemStatusOld ="";
var count=0;
var interv="";
var dtbjList="F";
var ifchart ="F";
var records=[];
var restTime=0;
function bidModeText(bidMode){
	var btext = "--";
	if(bidMode=="1")btext = "正向多次竞价";
	if(bidMode=="2")btext = "反向多次竞价";
	if(bidMode=="3")btext = "正向一次报价";
	if(bidMode=="4")btext = "反向一次报价";
	if(bidMode=="5")btext = "正向份额报价";
	if(bidMode=="6")btext = "反向份额报价";
	if(bidMode=="7")btext = "荷兰式竞价";
	return btext;
}
/**
* 输出long 的时间长度    如xx天xx小时xx分xx秒
*/
function spareTxt(spare){
	var result = "";
	if(spare>0){
    spareDays = Math.floor(spare / (24 * 60 * 60 * 1000));
    spareHouse= Math.floor((spare - spareDays * (24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
    spareMinutes  = Math.floor((spare - spareDays * (24 * 60 * 60 * 1000) - spareHouse * 60 * 60 * 1000) / (60 * 1000));
    spareSeconds  = Math.floor((spare - spareDays * (24 * 60 * 60 * 1000) - spareMinutes * 60 * 1000 - spareHouse * 60 * 60 * 1000) / 1000);
    result = spareDays > 0 ? "<span>" + spareDays + "</span>天" : "";
    result += spareHouse > 0 ? "<span>" + spareHouse + "</span>时" : "";
    result += spareMinutes > 0 ? "<span>" + spareMinutes + "</span>分" : "";    
    result += spareSeconds > 0 ? "<span>" + spareSeconds + "</span>秒" : "";   
    return result;
    }else if(spare==0){
    	return "已结束";
    }
   return "超时错误";
}
/**
 * 输出竞价期
 * @param status
 * @returns {String}
 */
function itemStatusTxt(status){
	//alert(status);
	var xx = "-";
	if(status=="0")xx = "未发布";
	if(status=="2")xx = "进行中";
	if(status=="3")xx = "暂停中";
	if(status=="A")xx = "尚未开始";
	if(status=="B")xx = "自由竞价";
	if(status=="C")xx = "限时竞价";
	if(status=="D")xx = "加价期";
	if(status=="E")xx = "行权期";
	if(status=="Z")xx = "结果处理中";
	if(status=="9")xx = "竞价结束";
	return xx;
}

//活动状态
function sessionStatusText(status){
	var stext = "--";
	if(status=="0")stext = "未发布";
	if(status=="1")stext = "审核中";
	if(status=="2")stext = "进行中";
	if(status=="3")stext = "暂停中";
	if(status=="4")btext = "发布未通过";
	if(status=="9")stext = "已结束";
	return stext;
}

/**
* //获取加价幅度控制
*
*/
function getIncrement(){
	//alert(incrementValue+incrementGroup+lastValue);
	return getIncrement1(incrementValue,incrementGroup,lastValue);
}

function getIncrement1(incrementValue,incrementGroup,lastValue){
	if(incrementValue.indexOf('|')==-1){
		increment = incrementValue;
		return increment;
	}else{
		var incrementGroupArray= incrementGroup.split("|");//1000|2000
		var incrementArray = incrementValue.split("|");//100|200
		for(var i =incrementGroupArray.length-1;i>=0;i--){
			//alert(lastValue+">="+incrementGroupArray[i]+"="+lastValue>=incrementGroupArray[i])
			if(parseFloat(lastValue)>=parseFloat(incrementGroupArray[i])){
				increment = parseFloat(incrementArray[i]);
				return increment;
			}
		}
	}
}

/**
* 将数值四舍五入后格式化.
*
* @param num 数值(Number或者String)
* @param cent 要保留的小数位(Number)
* @param isThousand 是否需要千分位 0:不需要,1:需要(数值类型);
* @return 格式的字符串,如'1,234,567.45'
* @type String
*/
function formatNumber(num,cent,isThousand) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))//检查传入数值为数值类型.
     num = "0";
if(isNaN(cent))//确保传入小数位为数值型数值.
cent = 0;
cent = parseInt(cent);
cent = Math.abs(cent);//求出小数位数,确保为正整数.
if(isNaN(isThousand))//确保传入是否需要千分位为数值类型.
isThousand = 0;
isThousand = parseInt(isThousand);
if(isThousand < 0)
isThousand = 0;
if(isThousand >=1) //确保传入的数值只为0或1
isThousand = 1;
    sign = (num == (num = Math.abs(num)));//获取符号(正/负数)
//Math.floor:返回小于等于其数值参数的最大整数
    num = Math.floor(num*Math.pow(10,cent)+0.50000000001);//把指定的小数位先转换成整数.多余的小数位四舍五入.
    cents = num%Math.pow(10,cent); //求出小数位数值.
    num = Math.floor(num/Math.pow(10,cent)).toString();//求出整数位数值.
cents = cents.toString();//把小数位转换成字符串,以便求小数位长度.
while(cents.length<cent){//补足小数位到指定的位数.
    cents = "0" + cents;
}

//ymyang 如果 小数位不为0，则显示小数位


if(cent!="0"){
	cents = '.' + cents ;
}else{
	cents = "";
}

if(isThousand == 0) //不需要千分位符.
    return (((sign)?'':'-') + num + cents);
//对整数部分进行千分位格式化.
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + num + cents);
}

//表的列表查询提交
function runningListSearch(){
	searchSubmit("hall","runningList");
}

//竞价页面底部弹出标的列表查询提交
function hallRunningListSearch(){
	hallSearchSubmit("hall","runningList");
}

//表的列表查询提交
function endListSearch(){
	searchSubmit("hall","endList");
}

//快速出价
function quick(itemId){
	var lastV= $("#value_"+itemId).html();
	var incGroup = $("#incGroup_"+itemId).val();
	var incValue = $("#incValue_"+itemId).val();
	var dc = $("#dc_"+itemId).val();
	increment = getIncrement1(incValue,incGroup,lastV);
	var myPrice=parseFloat(increment) + parseFloat(lastV);
	myPrice = formatNumber(myPrice,dc,0);
	bidSend(itemId,myPrice);
}

//查询分页列表数据
//查询分页列表数据（竞价大厅前台）
function searchSubmit(objName,listName){
	var this_url = ctx+spaceDomain+objName+"/rf";
	//alert(this_url);
	var formName = listName+"_form";
	var htmlName = "";
	var pageName = listName+"_page";
	var currentPage = $('#'+formName).find("input[name='page']").val();
	var tag = $('#'+listName+"_form").find("input[name='tag']").val();
	var htmlFlag = $('#'+formName).find("input[name='htmlFlag']").val();
	//alert(this_url);
	var scriptHtml = "";

	$.ajax({
		   type:'get',
		   url:this_url,
		   data:$("#"+formName).serialize(),
		   dataType:'json',
		   success: function(myData){
			   //alert(myData.total);
			   if("table"==tag){
					htmlName = listName + "_table";
					scriptHtml = listName + "_table_html";
					deleteAllRow(htmlName);
				}else{
					htmlName = listName + "_div";
					scriptHtml = listName + "_div_html";
					$('#'+htmlName).html("");
				}
			   var htmlData = "";
			   if(htmlFlag && htmlFlag=="T" ){
				   htmlData= myCompose(myData.rows);
			   }else{
				   htmlData = baidu.template(scriptHtml,eval(myData)); 
			   }
		   	   if(eval(myData).total>0){
				   $("#"+htmlName).append(htmlData);
		   	   }
			   if("#"+pageName){
				   pageWrite(myData.total,currentPage,objName,listName);
			   } 
		  }
	});	
	
	if("sessionList"==listName){
		//首页活动sesionlist才延迟加载sesion浏览次数
		setTimeout("loadSessionBorws()",600);
	}
}
function hallSearchSubmit(objName,listName){
	var this_url = ctx+spaceDomain+objName+"/rf";
	//alert(this_url);
	var formName = listName+"_form";
	var htmlName = "";
	var pageName = listName+"_page";
	var currentPage = $('#'+formName).find("input[name='page']").val();
	var tag = $('#'+listName+"_form").find("input[name='tag']").val();
	var htmlFlag = $('#'+formName).find("input[name='htmlFlag']").val();
	//alert(this_url);
	var scriptHtml = "";

	$.ajax({
		   type:'get',
		   url:this_url,
		   data:$("#"+formName).serialize(),
		   dataType:'json',
		   success: function(myData){
			   //alert(myData.total);
			   if("table"==tag){
					htmlName = listName + "_table";
					scriptHtml = listName + "_table_html";
					deleteAllRow(htmlName);
				}else{
					htmlName = listName + "_div";
					scriptHtml = listName + "_div_html";
					$('#'+htmlName).html("");
				}
			   var htmlData = "";
			   if(htmlFlag && htmlFlag=="T" ){
				   htmlData= myCompose(myData.rows);
			   }else{
				   htmlData = baidu.template(scriptHtml,eval(myData)); 
			   }
		   	   if(eval(myData).total>0){
				   $("#"+htmlName).append(htmlData);
		   	   }
			   if("#"+pageName){
				   pageWrite(myData.total,currentPage,objName,listName);
			   } 
			   showPicDiv();
		  }
	});	
	
	if("sessionList"==listName){
		//首页活动sesionlist才延迟加载sesion浏览次数
		setTimeout("loadSessionBorws()",600);
	}
}
//
function pageWrite(total,cPage,objName,listName){
	if("uctService" == objName){
		var pageSize = $('#'+listName+"_form").find("input[name='pageSize']").val();//$('#rows').val();
	}else{
		var pageSize = $('#'+listName+"_form").find("input[name='rows']").val();//$('#rows').val();
	}
	//alert(pageSize+"-"+total);
	//总页数
	var m = total % pageSize;
	var pageCount = m == 0 ? total / pageSize : (total-m) / pageSize + 1;
	
	var perGroup = 10;//每组显示5个分页,可配置
	var mm = pageCount % perGroup;
	var pageGroups = mm == 0 ? pageCount / perGroup : (pageCount-mm) / perGroup + 1;//分几组
	//alert(pageGroups);
	var mmm = cPage % perGroup;
	var cPageGroup = mmm == 0 ? cPage / perGroup : (cPage-mmm) / perGroup + 1;//分几组
	//alert(cPageGroup);
	var startp = ( cPageGroup -1 ) * perGroup +1;
	var endp = startp + perGroup -1;
	if(endp > pageCount) endp=pageCount;
	//alert(startp + "--"+endp);
	var ptxt="总计"+total+"条数据";
	if(pageCount>1){
		ptxt += ",共"+pageCount+"页,每页"+pageSize+"条。";
		if(startp>1){
			ptxt += "<a onclick='toPage("+(startp -1)+",\""+objName+"\",\""+listName+"\")'><<</a> ";
		}
		for ( var int = startp; int <= endp; int++) {
			if(int == cPage){
				ptxt += "<font>"+int+"</font> ";
			}else{
				ptxt += "<a onclick='toPage("+int+",\""+objName+"\",\""+listName+"\")'>"+int+"</a> ";
			}
		}
		if(endp<pageCount){
			ptxt += "<a onclick='toPage("+(endp + 1)+",\""+objName+"\",\""+listName+"\")'>>></a> ";
		}		
	}

	$("#"+listName+"_page").html(ptxt);
}

function toPage(pn,objName,listName){
	if("uctService" == objName){
		$('#'+listName+"_form").find("input[name='pageIndex']").val(pn);
		searchUcUser(listName);
		$('#'+listName+"_form").find("input[name='pageIndex']").val(1);
	}else{
		$('#'+listName+"_form").find("input[name='page']").val(pn);
		searchSubmit(objName,listName);
		$('#'+listName+"_form").find("input[name='page']").val(1);
	}
	
}
function deleteAllRow(tableId){
	var tb = document.getElementById(tableId);
	if(tb){
	     var rowNum=tb.rows.length;
	     for (i=1;i<rowNum;i++){
	         tb.deleteRow(i);
	         rowNum=rowNum-1;
	         i=i-1;
	     }
     }
}
//查询提交
function sessionListSearch(){
	searchSubmit("session","sessionList");
}

function getIds(){
	var itermIds = "";
	$("input[name='ids']").each(function(){
		itermIds += $(this).val()+",";
	});	
	return itermIds;
}

//加价
function baojiaAdd(){
	//alert(n);
	var myPrice = $("#addPrice").val();
	if(myPrice==undefined || myPrice==""){
		alert("请输入价格");
		return;
	}
	
	if(confirm("你确实要加价到："+myPrice+"吗?")){
		var bidSendUrl = ctx+spaceDomain+'hall/bidAdd';
		$.ajax({
			   type:'get',
			   url:bidSendUrl,
			   data:{itemId:itemId,myPrice:myPrice},
			   dataType:'json',
			   success: function(myData){
					if(myData.flag=="T"){
						alert("加价成功");
						$("#baojiaBtn").hide();
					}else{
						alert(myData.msg);
					}
			  }
		});	
	}
}

//行权
function xingquan(flag){
	if("T"==flag){
		if(confirm("你确实要行权吗?")){
			var bidSendUrl = ctx+spaceDomain+'hall/bidXingquan';
			$.ajax({
				   type:'get',
				   url:bidSendUrl,
				   data:{itemId:itemId,flag:flag},
				   dataType:'json',
				   success: function(myData){
						if(myData.flag=="T"){
							alert("行权成功");
							$("#btnAllowFirst").hide();
						}else{
							alert(myData.msg);
						}
				  }
			});	
		}
	}else{
		
	}
}

function addPrice(n){
	if("A"==n){
		myPrice = formatNumber(onceValue,decimalCount,0);
	}else{
		myPrice = parseFloat(n* increment) + parseFloat(lastValue);
	}
	myPrice = formatNumber(myPrice,decimalCount,0);
	bidSend(itemId,myPrice);
}

function baojia(myPrice){
	myPrice = formatNumber(myPrice,decimalCount,0);
	bidSend(itemId,myPrice);
}
function yingJia(){
	var myPrice = formatNumber(firstValue,decimalCount,0);
	bidSend(itemId,myPrice);
}

function baojiaFirst(){
	var myPrice = formatNumber(firstValue,decimalCount,0);
	bidSend(itemId,myPrice);
}
//正常报价
function bidSend(itemId,myPrice){
	//alert(n);
	//var myPrice = $("#my_price").val();
	if(confirm("你确实要报价"+myPrice+"吗?")){
		var bidSendUrl = ctx+spaceDomain+'hall/bidSend';
		$.ajax({
			   type:'get',
			   url:bidSendUrl,
			   data:{itemId:itemId,myPrice:myPrice},
			   dataType:'json',
			   success: function(myData){
				   //alert(myData);
					if(myData.flag=="T"){
						alert("报价成功");
						$("#btnAllowFirst").hide();
					}else{
						alert(myData.msg);
					}
			  }
		});	
	}
}


//标的列表定时刷新：当前价格 报价次数 最高报价人
function myLoad(){
	var itermIds =getIds(); 
	$.ajax({
		   type:'get',
		   url:ctx+spaceDomain+'hall/cacheList',
		   data:{ids:itermIds},
		   dataType:'json',
		   success: function(myData){
			   //alert(myData.total);
			   if(myData.total>0){
			     myData.rows.forEach(function(e){
			    	loadDo(e);
				 });  
			   }
		  }
	});	
}

function loadDo(e){
	 $("#value_"+e.itemId).html(e.lastValue) ;
	 $("#user_"+e.itemId).html(e.userName) ;
	 $("#status_"+e.itemId).html(itemStatusTxt(e.status)) ;
     $("#sptime_"+e.itemId).html(spareTxt(e.spareTime)) ;
     if(bidMode=="1"){
    	 if(e.status=="B"|| e.status=="C"){
        	 $("#quick_"+e.itemId).show();
         }else{
        	 $("#quick_"+e.itemId).hide();
         }
     }
     var lastNum =$("#num_"+e.itemId).html();
     $("#num_"+e.itemId).html(e.bidTimes) ;
     //alert(loginUser);
     //判断我是否是最优报价
     if(loginUser==e.userName){
    	 document.getElementById("value_"+e.itemId).className = 'cur';
    	 //$("#itli_"+e.itemId).addClass("it_box_s") .removeClass("it_box");
     }else{
    	 document.getElementById("value_"+e.itemId).className = 'red';
    	// $("#itli_"+e.itemId).addClass("it_box") .removeClass("it_box_s");
     }
     //动态报价的表格样式的变化
     if(dtbjList=="T"){
	     if(e.bidTimes==0){ //没有报价绿色
	    	 document.getElementById("item_"+e.itemId).className = "cg2";
	     }else if(lastNum=="------"){
	    	 document.getElementById("item_"+e.itemId).className = "cg1";
	     }else{ //有报价
	    	 if(lastNum !='' && e.bidTimes!= lastNum){ //有变化黄色,10秒后变红
	    		 document.getElementById("item_"+e.itemId).className = "cg3";
	    		 setTimeout("document.getElementById('item_"+e.itemId+"').className='cg1';",60000);
	    	 }
	     }
	     
	     //判断若此标的已经结束则，移除此行
	     if("Z"==e.status || "9"==e.status){
	    	 $("#item_"+e.itemId).remove();
	     }
     }
}

function bidGet(){
	var bidGetUrl = ctx+spaceDomain+'hall/bidGet';
	var bidNum=$("#bid_num").html();
	$.ajax({
		   type:'get',
		   url:bidGetUrl,
		   data:{itemId:itemId,bidNum:currentBidTimes},
		   dataType:'json',
		   async:false,
		   success: function(myData){
				   if(bidMode=="1"){
					   bidGetBack_1(myData);
				   }else  if(bidMode=="3"){
					   bidGetBack_3(myData);
				   }else  if(bidMode=="7"){
					   bidGetBack_7(myData);
				   }else  if(bidMode=="5"){
					   bidGetBack_5(myData);
				   }else{
					  //alert("其他竞价方式请在hall.js文件中补充");
				   }
		  }
	});	
}

//初始化切换请求数据
function initHall(itemId){
	$.ajax({
		   type:'post',
		   url:ctx+spaceDomain+'hall/item/'+itemId,
		   dataType:'json',
		   success: function(myData){
			   initHallBack(myData.item,myData.price,myData.apply,myData.myLevel);
		  }
	});		
}
function gotohall(id){
	if(itemId!=id){
		itemId = id;
		initHall(itemId);
	}
	$("#hall").show();
	$("#sessionDesc").hide();
	
	//window.location.href=ctx+spaceDomain+'hall/item/'+id;
}
//初始化切换回调处理
function initHallBack(item,price,apply,myLevel){
	//初始化变量
	currentBidTimes="-1";
	myLevel = myLevel;
	decimalCount = item.decimalCount;
	///如果lastValue为空取firstValue;
	firstValue = price.firstValue;
	lastValue = price.lastValue;
	if(lastValue=="0"|| lastValue=="")lastValue = price.firstValue;
	incrementGroup =item.incrementGroup;
	incrementValue =item.incrementValue;
	allowFirstValue = item.allowFirstValue;
	increment=getIncrement();
	updateTimes=item.allowUpdateTimes;
	onceValue =item.oncevalue;
	lastUser = price.userName;//最高报价人
	vFlag = item.vFlag;
	groupId =item.groupId;
	//初始化页面
	initHallPage(item,price,apply,myLevel);
	//alert(apply);
	if(apply){
		$("#apply_item").hide();
	}else{
		$("#apply_item").show();
	}
	
	if(ifchart=="T"){
		initCharts(item.itemId);
	}
	//如果没有启动定时器，启动定时器
	if(interv==""){
		interv = setInterval(bidGet,intervalV);
	}
}

function initCharts(itemId){
	records=[];
	$.ajax({
		   type:'get',
		   url:ctx+spaceDomain+'hall/jingjiaList?itemId='+itemId+"&methodKey=jingjiaList",
		   dataType:'json',
		   success: function(myData){
			   var rows = myData.rows;
			   var j=0;
			   for(var i=myData.total-1;i>=0;i--){
				   var row= rows[i];
				   var newx =parseFloat(j*10);
				   var newy =parseFloat(row.bidValue);
				   var newPoint = [newx,newy];
				   records[j] =newPoint;
				   j++;
			   }
			   drawIt('container');
		  }
	});	
}

//获取content列表信息
function getContentList_bmxz(listName,objId,objType,contentType){
	
	$("#contentApply_objId").val(objId);
	$("#contentApply_objType").val(objType);
	searchSubmit("hall","content_apply");
	layer.open({
		   type: 1,
		   title: "<div id='divstep'>第一步：阅读报名须知</div>",
		   closeBtn: 1,
		   area: ['700px', '320px'],
		   shadeClose: true,
		   content:  $("#content_notice_bmxzs") 
		});
		$("#div_content_bmxz").show();
		$("#apply_window").hide();
	
}
//获取content单对象列表信息
function getContentObj(infoId){
	$.ajax({
		   type:'get',
		   url:ctx+spaceDomain+'content/rf/'+infoId,
		   dataType:'json',
		   success: function(myData){
			   getContentCallBack(myData.flag,myData.item);
		  }
	});	
}
//提交竞买申请
function applySave(){
	var this_url = ctx+spaceDomain+"hall/apply";
	if(!$("#apply_form").form('validate')){
	    return false;
	}
	if(strUtil.isNull($("#apply_phone").val())){
		layer.tips('请输入联系电话！', '#apply_phone', {tips: 2});
		$("#apply_phone").focus();
		return false;
	}
	if(strUtil.isNull($("#apply_mobile").val())){
		layer.tips('请输入手机号！', '#apply_mobile', {tips: 2});
		$("#apply_mobile").focus();
		return false;
	}
	if(strUtil.isNull($("#apply_email").val())){
		layer.tips('请输入联系邮箱！', '#apply_email', {tips: 2});
		$("#apply_email").focus();
		return false;
	}
	
	var result = applyCheck();
	if("T"!=result.flag) return false;
	$("#btn_apply_save").hide();
	$.ajax({
		   type:'post',
		   url:this_url,
		   data:$("#apply_form").serialize(),
		   dataType:'json',
		   success: function(myData){
			   if("T"==myData.flag){
				   $("#apply_session").hide();
				   $("#apply_item").hide();
				   alert("申请提交成功，请等待处理！");
				   layer.close(0);
				   layer.close(1);
				   window.location.reload(true);
			   }else{
				   $("#btn_apply_save").show();
				   alert("处理失败："+myData.msg);
			   }
		   }
	});
	$('#apply_window').dialog('close');
}

//校验是否发起过竞买申请
function applyCheck(){
	var result = "";
	$('#apply_form').find("input[name='sessionId']").val(sessionId);
	var this_url = ctx+spaceDomain+"hall/applyCheck";
	$.ajax({
		   type:'get',
		   url:this_url,
		   data:$("#apply_form").serialize(),
		   dataType:'json',
		   async: false,//同步
		   success: function(myData){result = myData;}
	});
	return result;
}

function initSelect(elemid,selVl){
	var myobj=document.getElementById(elemid);
	if(myobj==null)return;
	for ( var i = 0; i < myobj.options.length; i++) {
		if (myobj.options[i].value == selVl) {
			myobj.selectedIndex = i;
		}
	}
 }

/*
 * 计算下一下时间点
 */
function getNextTime(startTime,ss){
	var date = new Date(startTime.replace(/-/g, " / "));//要计算的时间
	var StateTimeofMinute = date.getTime();//.getMinutes();//获取分钟属性
	date = new Date(StateTimeofMinute+ss*1000); //设置分钟属性
	return date.format("yyyy-MM-dd hh:mm:ss");
}

//获对应标的报价列表信息
function getItemInfoList(itemId){
	var tabId = "itemInfoList_table";
	deleteAllRow(tabId);
	$.ajax({
		   type:'get',
		   url:ctx+spaceDomain+'hall/itemInfoList',
		   data:{itemId:itemId},
		   dataType:'json',
		   async: false,//同步
		   success: function(myData){
		   	   if(myData.total!=null && eval(myData).total>0){
		   		   var htmlData = baidu.template('itemInfoList_html',eval(myData));
		   		   $("#"+tabId).html(htmlData);
		   	   }
		  }
	});	
}

//获取标的图片列表
function getItemPicAttaList(itemId,listName){
	//deleteAllRow(tabId);
	//alert(uct_server+"|"+myAttaServer+"|"+itemId);
	//http://uc.utrm.com/sweb/attachment/service/doService/?sysPass=chtrans2013&MethodCode=attalist&objType=bidUpPicOne&objId=f32466eb9ba54d948fdd84fa43ea0f4d
	var this_url = myAttaServer+'attachment/service/doService/';
	//alert(this_url);
//$("#"+listName+"_div").html("");
	$.ajax({
		   type:'get',
		   url:this_url,
		   data:{sysPass:"chtrans2013",MethodCode:"attalist",objType:"bidUpPicOne",objId:itemId},
		   dataType:'jsonp',
		   jsonp: "callback",
		   success: function(data){
			   	if("true"==data.result){
			   		//alert(data.result);
				   //组装数据
				   //var total = data.entity.count;
				   //var rows = data.entity.pageObjects;
				   var myData = new Object();
				   myData.total = data.entity.length;
				   myData.rows = data.entity;
			   		var list = data.entity;
			   		var htmls = "";
			   		//alert(list.length);
				   for(var i=0;i< list.length;i++){
					   var picUrl = list[i].downloadUrl+list[i].sid+"."+list[i].attachmentType;
					   htmls+="<li style='background:url("+picUrl+")50% 0 no-repeat;'></li>";
				   }
				 // var htmlData = baidu.template(listName+'_html',eval(myData));  
				  // if(eval(myData).total>0){
				// alert(htmls);
				   $("#"+listName).html(htmls);
			   	  // }
			   	  //alert(rows);
			   }
		  }
	});	
}

//添加阅读记录
function submitReadRecord(userId,userName,logName,logContent,sessionName,itemName){
	var this_url = ctx+spaceDomain+"hall/readRecord";	
	var objectId="";
	var objectType="";
	var objectName="";
	$('#apply_form').find("input[name='sessionId']").val(sessionId);
	if("1"==sessionType || "2"==sessionType){
		$('#apply_form').find("input[name='itemId']").val("0");
		objectId= sessionId;
		objectType="session";
		objectName=sessionName;
	}else{
		$('#apply_form').find("input[name='objName']").val($("#itemName").html());
		$('#apply_form').find("input[name='itemId']").val(itemId);
		if(itemId=="0"){
			objectId= sessionId;
			objectType="session";
			objectName=sessionName;
		}else{
			objectId= itemId;
			objectType="item";
			objectName=itemName;
		}
	}
	$.ajax({
		   type:'post',
		   url:this_url,
		   data:"sessionId="+sessionId+"&userId="+userId+"&userName="+userName+"&logName="+logName+"&logContent="+logContent+"&objectType="+objectType+"&objectId="+objectId+"&objectName="+objectName,
		   dataType:'json',
		   success: function(myData){
			   showTwoStep();
		   }
	});
}

